package com.sgb.kjwl.utils;

import android.content.Context;
import android.graphics.drawable.GradientDrawable;
import android.view.View;

import androidx.annotation.ColorRes;

public class ShapeUtils {

    public void setShapeBackgroundColor(View view,@ColorRes int color){
        GradientDrawable background = (GradientDrawable) view.getBackground();
        background.setColor(view.getContext().getResources().getColor(color));
    }

    public void setShapeBackground(View view,int color){
        GradientDrawable background = (GradientDrawable) view.getBackground();
        background.setColor(color);
    }

    public void setShapeBackground(View view){
        int[] colors = { 0xfe7447, 0xf75925};
        GradientDrawable gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, colors);
        view.setBackground(gradientDrawable);
    }

    public void setShapeBackgroundRadius(View view, int radius){
        GradientDrawable mGroupDrawable= (GradientDrawable) view.getBackground();
        mGroupDrawable.setCornerRadius(radius);
        view.setBackground(mGroupDrawable);
    }
}
